// import { TeamLeaderServiceFee } from '../entity/TeamLeaderServiceFee';
// import { ExpertCommission } from '../entity/ExpertCommission';
import { Config, Provide } from '@midwayjs/decorator';
import { BaseService } from '@cool-midway/core';
import { InjectEntityModel } from '@midwayjs/typeorm';
import { Repository } from 'typeorm';
import { OrdersEntity } from '../entity/orders';

@Provide()
export class OrdersService extends BaseService {
  @InjectEntityModel(OrdersEntity)
  entity: Repository<OrdersEntity>;

  async upsert(data) {
    return await this.entity.upsert(data, {
      conflictPaths: ['order_number', 'id'],
    });
  }

  // async all(data: any = {}) {
  //   return await this.entity
  //     .createQueryBuilder('orders')
  //     .where('orders.data_date = :data_date', {
  //       data_date: data.data_date,
  //     })
  //     .andWhere('orders.store_name = :store_name', {
  //       store_name: data.store_name,
  //     })
  //     .andWhere('orders.status != "已关闭"')
  //     .leftJoinAndMapOne(
  //       'orders.teamLeaderServiceFee',
  //       TeamLeaderServiceFee,
  //       'teamLeaderServiceFee',
  //       'teamLeaderServiceFee.product_id = orders.product_id'
  //     )
  //     .leftJoinAndMapOne(
  //       'orders.expertCommission',
  //       ExpertCommission,
  //       'expertCommission',
  //       'expertCommission.product_id = orders.product_id'
  //     )
  //     .getMany();
  // }
}
